home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 030 / lastlog.arc / LASTLOG.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1987-02-18  |  4.7 KB  |  156 lines

  1. program LastLog;
  2.  
  3.     { Lastlog.com was written to provide the LAN user    }
  4.     { with a little more comfort in knowing that no one  }
  5.     { has been using his LOGIN_NAME.                     }
  6.     {                                                    }
  7.     { Lastlog will display the time and date when a user }
  8.     { last logged into the LAN.                          }
  9.     { It accepts a parameter which is used to specify    }
  10.     { the filename of the individual's LASTLOG file.     }
  11.     { If no file exists, (first time it is run), a new   }
  12.     { file is created in the user's HOME directory.      }
  13.     { All users have a Home directory that has the       }
  14.     { same name as their LOGIN_NAME                      }
  15.     { Lastlog is invoked by a common Login Script that   }
  16.     { is used by all LAN users.                          }
  17.     { Here is our current Login Script.                  }
  18.     { ************************************************** }
  19.     { MAP DISPLAY ON                                     }
  20.     { DOS SET USER = "%LOGIN_NAME"                       }
  21.     { WRITE "Logging in:  %FULL_NAME on %DAY_OF_WEEK ";  }
  22.     { write "%MONTH_NAME  %DAY at %HOUR:%MINUTE %AM_PM"  }
  23.     { MAP DISPLAY OFF                                    }
  24.     { MAP S1:=SYS:PUBLIC                                 }
  25.     { MAP S2:=SYS:WIN                                    }
  26.     { MAP S3:=SYS:DW                                     }
  27.     { MAP S4:=SYS:123V1                                  }
  28.     { MAP S5:=SYS:DOS%OS_VERSION                         }
  29.     { MAP S6:=SYS:%MACHINE                               }
  30.     { MAP S7:=SYS:COMMON                                 }
  31.     { COMSPEC = S5:COMMAND.COM                           }
  32.     { MAP P:=IOL:SNAGATE                                 }
  33.     { MAP S:=IOL:SHARED                                  }
  34.     { MAP *1:=IOL:%LOGIN_NAME                            }
  35.     { MAP DISPLAY ON                                     }
  36.     { #LASTLOG %LOGIN_NAME                               }
  37.     { DISPLAY SYS:PUBLIC\NETNEWS.TXT                     }
  38.     { WAIT                                               }
  39.  
  40.  
  41. type
  42.    CommandString = string[127];
  43.    TimeString    = string[8];
  44.    DateStr       = string[18];
  45.  
  46. var
  47.   Buffer               : CommandString;
  48.   CL                   : CommandString absolute cseg:$80;
  49.   InFile,OutFile       : Text;
  50.   Last                 : string[80];
  51.   Temp                 : string[12];
  52.  
  53.  
  54. function time: TimeString;
  55. type
  56.   regpack = record
  57.               ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
  58.             end;
  59.  
  60. var
  61.   recpack:          regpack;
  62.   ah,al,ch,cl,dh:   byte;
  63.   hour,min,sec:     string[2];
  64.  
  65. begin
  66.   ah := $2c;
  67.   with recpack do
  68.   begin
  69.     ax := ah shl 8 + al;
  70.   end;
  71.   intr($21,recpack);
  72.   with recpack do
  73.   begin
  74.     str(cx shr 8,hour);
  75.     str(cx mod 256,min);
  76.     str(dx shr 8,sec);
  77.   end;
  78.   if Length(min) < 2 then min := '0' + min;
  79.   if Length(sec) < 2 then sec := '0' + sec;
  80.   time := hour+':'+min+':'+sec;
  81. end;
  82.  
  83.  
  84.  
  85. function Date: DateStr;
  86. type
  87.   regpack = record
  88.               ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
  89.             end;
  90.  
  91. var
  92.   recpack:       regpack;
  93.   month,day:     string[2];
  94.   year:          string[4];
  95.   mth :          string[9];
  96.   dx,cx,mth_num,code: integer;
  97.  
  98. begin
  99.   with recpack do
  100.   begin
  101.     ax := $2a shl 8;
  102.   end;
  103.   MsDos(recpack);
  104.   with recpack do
  105.   begin
  106.     str(cx,year);
  107.     str(dx mod 256,day);
  108.     str(dx shr 8,month);
  109.   end;
  110.   if Length(month) < 2 then month := '0' + month;
  111.   if Length(day)   < 2 then day   := '0' + day;
  112.   val(month,mth_num,code);
  113.   case mth_num of
  114.      1  : mth := 'January';
  115.      2  : mth := 'February';
  116.      3  : mth := 'March';
  117.      4  : mth := 'April';
  118.      5  : mth := 'May';
  119.      6  : mth := 'June';
  120.      7  : mth := 'July';
  121.      8  : mth := 'August';
  122.      9  : mth := 'September';
  123.     10  : mth := 'October';
  124.     11  : mth := 'November';
  125.     12  : mth := 'December';
  126.   end;
  127.   date := mth+' '+day+', '+year;
  128. end;
  129.  
  130. begin
  131.      Textcolor(LightGreen);
  132.  
  133.      Last   := '............';
  134.      Buffer := CL;
  135.      Delete(Buffer,1,1);
  136.      Temp   := Buffer + '.LOG';
  137. {$i-}
  138.      Assign(Infile,Temp);
  139.      Reset(Infile);
  140.      Readln(Infile,Last);
  141.         if IOresult > 0 then begin
  142.           Textcolor(Yellow);
  143.           WriteLn('No LAST-LOGIN record found for ID .. [',Buffer,']');
  144.           Writeln('Creating ... ',Temp)
  145.                              end
  146.           else begin
  147.      WriteLn('Last Login for ',Buffer,' occurred at : ',Last);
  148.      Close(Infile)
  149.                end;
  150. {$i+}
  151.      Assign(Outfile,Temp);
  152.      ReWrite(Outfile);
  153.      WriteLn(Outfile,time,' on ',date);
  154.      Close(Outfile)
  155. end.
  156.